package codegen.util.database;

import java.sql.Types;

public enum JdbcType {
	TYPE_BIGINT{
		public String getName() {
			return "BIGINT";
		}
	},
	TYPE_VARCHAR{
		public String getName() {
			return "VARCHAR";
		}
	},
	TYPE_DOUBLE{
		public String getName() {
			return "DOUBLE";
		}
	},
	TYPE_TINYINT{
		public String getName() {
			return "TINYINT";
		}
	},
	TYPE_DATE{
		public String getName() {
			return "DATE";
		}
	},
	TYPE_TIMESTAMP{
		public String getName() {
			return "TIMESTAMP";
		}
	},
	TYPE_INTEGER{
		public String getName() {
			return "INTEGER";
		}
	};
	abstract public String getName();
	public static JdbcType transfer(int type) {
		switch (type) {
		case Types.BIGINT:
			return TYPE_BIGINT;
		case Types.SMALLINT:
		case Types.TINYINT:
		case Types.BOOLEAN:
			return TYPE_TINYINT;
		case Types.BLOB:
			return TYPE_VARCHAR;
		case Types.CLOB:
			return TYPE_VARCHAR;
		case Types.VARCHAR:
		case Types.CHAR:
			return TYPE_VARCHAR;
		case Types.DATE:
			return TYPE_DATE;
		case Types.DECIMAL:
		case Types.DOUBLE:
		case Types.FLOAT:
		case Types.NUMERIC:
			return TYPE_DOUBLE;
		case Types.INTEGER:
			return TYPE_INTEGER;
		case Types.TIMESTAMP:
			return TYPE_TIMESTAMP;
		default:
			return TYPE_VARCHAR;
		}
	}

}
